package com.objectproject.main.service.subsystem.builder;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.objectproject.main.dao.MyGroupDAOImpl;
import com.objectproject.main.enumeration.ValueType;
import com.objectproject.main.model.MyGroup;
import com.objectproject.main.model.MyObject;
import com.objectproject.main.model.MyProperty;
import com.objectproject.main.service.subsystem.policy.PolicyAndConfigurationRepository;


public class MyPropertyBuilder {
	
	
	private long propertyId = 0L;//optional
	private MyGroup modificationAuth = new MyGroup();//optional
	private boolean isHidden = false;//optional
	private boolean isStatic = false;//optional
	private boolean isSystemProperty = false;//optional
	private ValueType typeOfValue = null;
	private MyObject typeObjectQualifier = null;//optional
	private boolean viewMini = false;//optional
	private boolean viewSimple = false;//optional
	private boolean viewCard = false;//optional
	private boolean viewNormal =false;//optional
	//private boolean valid = true;//not used
	private int dedicatedLocaleId;//optional
	
	
	//set of optional
	private int priority = 0;
	private String label = null;
	private long valueId = 0L;
	//private Object value = null;//it will be derived by value_id.
	private String helpText = null;
	
	public MyPropertyBuilder(ValueType typeOfValue){
		this.typeOfValue = typeOfValue;
		this.modificationAuth.setGroupId(PolicyAndConfigurationRepository.ROOT_GROUP_ID);
	}
	
	public MyPropertyBuilder propertyId(long propertyId){
		this.propertyId = propertyId;
		return this;
	}
	
	public MyPropertyBuilder modificationAuth(MyGroup modificationAuth){
		this.modificationAuth = modificationAuth;
		return this;
	}
	
	public MyPropertyBuilder isHidden(boolean isHidden){
		this.isHidden = isHidden;
		return this;
	}
	
	public MyPropertyBuilder isStatic(boolean isStatic){
		this.isStatic = isStatic;
		return this;
	}
	
	public MyPropertyBuilder isSystemProperty(boolean isSystemProperty){
		this.isSystemProperty = isSystemProperty;
		return this;
	}
	
	public MyPropertyBuilder typeOfValue(ValueType typeOfValue){
		this.typeOfValue = typeOfValue;
		return this;
	}
	
	public MyPropertyBuilder typeObjectQualifier(MyObject typeObjectQuailfier){
		this.typeObjectQualifier = typeObjectQuailfier;
		return this;
	}
	
	public MyPropertyBuilder viewMini(boolean viewMini){
		this.viewMini = viewMini;
		return this;
	}
	
	public MyPropertyBuilder viewSimple(boolean viewSimple){
		this.viewSimple = viewSimple;
		return this;
	}
	
	public MyPropertyBuilder viewCard(boolean viewCard){
		this.viewCard = viewCard;
		return this;
	}
	
	public MyPropertyBuilder viewNormal(boolean viewNormal){
		this.viewNormal = viewNormal;
		return this;
	}
	
	public MyPropertyBuilder dedicatedLocaleId(int dedicatedLocaleId){
		this.dedicatedLocaleId = dedicatedLocaleId;
		return this;
	}
	
	public MyPropertyBuilder propertyDetail(MyProperty propertyDetail){
		this.priority = propertyDetail.getPriority();
		this.label = propertyDetail.getLabel();
		this.valueId  = propertyDetail.getValueId();
		this.helpText = propertyDetail.getHelpText();
		return this;
	}
	
	public MyProperty build(){
		MyProperty myProperty = new MyProperty();
		myProperty.setPropertyId(propertyId);
		myProperty.setModificationAuth(modificationAuth);
		myProperty.setHidden(isHidden);
		myProperty.setStatic(isStatic);
		myProperty.setSystemProperty(isSystemProperty);
		myProperty.setTypeOfValue(typeOfValue);
		myProperty.setTypeObjectQualifier(typeObjectQualifier);
		myProperty.setViewMini(viewMini);
		myProperty.setViewSimple(viewSimple);
		myProperty.setViewCard(viewCard);
		myProperty.setViewNormal(viewNormal);
		myProperty.setDedicatedLocaleId(dedicatedLocaleId);
		
		myProperty.setPriority(priority);
		myProperty.setLabel(label);
		myProperty.setValueId(valueId);
		myProperty.setHelpText(helpText);
		
		return myProperty;
		
	}
}
